<template>
    <div class="newsinfo-container">
        <h3>{{data.title}}</h3>
        <p>
            <span>发表时间:{{data.add_time|dateFormat("YYYY/MM/DD")}}</span>
            <span>点击次数:{{data.click}}</span>
        </p>
        <hr>
        <div v-html="data.content"></div>
        <hr>
        <!-- 调用评论子组件 -->
        <comment-box :id="id"></comment-box>
    </div>
</template>
<script>
import Comment from '../subcomponents/Comment.vue';
export default {
    data(){
        return {
            id:this.$route.params.id,
            data:{}
        }
    },
    created(){
        this.getNewsInfo();
    },
    methods:{
        getNewsInfo(){
            this.$http.get('api/getnew/'+this.id).then((res)=>{
                if(res.body.status==0){
                    this.data=res.body.message[0];
                }
            });
        }
    },
    //注册子组件
    components:{
        commentBox:Comment
    }
}
</script>
<style lang="scss" scoped>
.newsinfo-container{
    padding:4px;
    h3{
        font-size: 14px;
    }
    >div{
        padding:6px;
    }
}
</style>

